package cn.zjnu.struts;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import cn.zjnu.DAO.LaboratoryDAO;
import cn.zjnu.bean.Laboratory;
import cn.zjnu.bean.Rooms;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class LaboratoryAction extends ActionSupport{
	private String LabPlaPro;
	private String LabType;
	private String OwneshipUnit;
	LaboratoryDAO labo=new LaboratoryDAO();
	public String getLabPlaPro() {
		return LabPlaPro;
	}
	public void setLabPlaPro(String labPlaPro) {
		LabPlaPro = labPlaPro;
	}
	public String getLabType() {
		return LabType;
	}
	public void setLabType(String labType) {
		LabType = labType;
	}
	public String getOwneshipUnit() {
		return OwneshipUnit;
	}
	public void setOwneshipUnit(String owneshipUnit) {
		OwneshipUnit = owneshipUnit;
	}
	public String execute() throws ClassNotFoundException, SQLException{
		labo.connect();
		ResultSet rs=labo.Query(LabPlaPro, LabType, OwneshipUnit);
		List laboratorys= new ArrayList<Laboratory>();
		while(rs.next()){
			String LabId,LabName,LabType,LabPlaPro,OwneshipUnit;
			LabId=rs.getString("LabId");
			LabName=rs.getString(2);
			LabType=rs.getString("LabType");
			LabPlaPro=rs.getString("LabPlaPro");
			OwneshipUnit=rs.getString("OwneshipUnit");
			Laboratory laboratory =new Laboratory(LabId,LabName,LabType,LabPlaPro,OwneshipUnit);
			laboratorys.add(laboratory);
		}
		ActionContext ct=ActionContext.getContext();
		ct.put("laboratorys", laboratorys);
		
		return this.SUCCESS;
	}
}
